<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('user_hutong', function (Blueprint $table) {
            $table->engine  = 'InnoDB';
            $table->comment('用户互通');

            $table->increments('id');
            $table->integer('create_time')->comment('创建时间')->unsigned()->default(0);
            $table->integer('game_id')->comment('游戏id')->unsigned()->default(0);
            $table->integer('channel')->comment('渠道')->unsigned()->default(0);
            $table->string('channel_openid', 128)->comment('渠道openid')->default('');
            $table->char('account_openid', 32)->comment('官方账号openid')->default('');
            $table->integer('user_id')->comment('绑定到哪个user_id')->unsigned()->default(0);

            $table->index('game_id');
            $table->index('channel');
            $table->index('channel_openid');
            $table->index('account_openid');
            $table->index('user_id');
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('user_hutong');
    }
};
